// pages/liana/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    setInter: '',
  },





  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {



  },
  //开始订单计时器
  startSetInter: function() {
    var that = this;
    that.data.setInter = setInterval(
      function() {
  
        var time = that.data.time
        var times = (new Date()).getTime();
       var s =  times - time


        var my_time = s;
        getDuration(my_time);

        function getDuration(my_time) {
          var days = my_time / 1000 / 60 / 60 / 24;
          var daysRound = Math.floor(days);
          var hours = my_time / 1000 / 60 / 60 - (24 * daysRound);
          var hoursRound = Math.floor(hours);
          var minutes = my_time / 1000 / 60 - (24 * 60 * daysRound) - (60 * hoursRound);
          var minutesRound = Math.floor(minutes);
          var seconds = my_time / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
          console.log('转换时间:', daysRound + '天', hoursRound + '时', minutesRound + '分', seconds + '秒');
          var timeu = hoursRound + ':' + minutesRound + ':' + seconds
          return timeu;
        }



 

        //函数
        console.log("时间差", s)
      }, 100);
  },


  //清除计时器 即清除setInter
  endSetInter: function() {

    var that = this;
    clearInterval(that.data.setInter)
  },




  dianji: function() {

    var time = (new Date()).getTime();
 
    this.setData({
      time: time
    })
    var ss = "" + time + ""
    this.startSetInter();
    wx.showModal({
      title: '温馨提示',
      content: ss,
      success(res) {
        if (res.confirm) {
          wx.showToast({
            title: '获取成功',
            icon: 'success',
            duration: 1500
          })
          //复制下来了
          wx.setClipboardData({
            data: ss,
            success: function(res) {
              wx.getClipboardData({

                success: function(res) {
                  console.log(res.data)
                }
              })
            }
          })



          console.log('用户点击确定')

        } else if (res.cancel) {
          console.log('用户点击取消')
          wx.showToast({
            title: '获取失败',
            icon: 'loading',
            duration: 1500
          })
        }
      }
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})